<%@page import="com.charlie.beans.Users"%>
<%@page import="com.charlie.beans.Groups"%>
<%@page import="java.util.List"%>

<%@include file="/header.jsp"%>

<%
    Groups group = (Groups) request.getAttribute("group");
    List<Users> allUsers = (List<Users>) request.getAttribute("allUsers");
    List<String> groupUsersId = (List<String>) request.getAttribute("groupUsersId");
%>

<div class="left_side">
    <jsp:include page="/blocks/conditionalLeftBar.jsp" />
</div>

<div class="right_side">
    <h2 style="text-align: center;">Select users to delete from group <%=group.getName()%></h2>
    <div class="white_block">
        <h2 style="text-align: center;">Users list: </h2>
        <form method="post">
            <div overflow="scroll">
                <table class="typycal_table">
                    <thead>   
                        <tr>
                            <th></th>
                            <th>ID</th>
                            <th>CREATION DATE</th>
                            <th>EMAIL</th>
                            <th>NAME</th>
                            <th>LAST NAME</th>
                        </tr>
                    </thead>
                    <tbody>
                        <%
                            for (Users u : allUsers) {
                                if (!u.getFirstName().equals("admin")) {
                                    if (groupUsersId.contains(u.getUsersId().toString())) {
                        %>
                        <tr>
                            <td><input type="checkbox" name="id" value="<%=u.getUsersId()%>"></td>
                            <td><%=u.getUsersId()%> </td>
                            <td><%=u.getCreationDate()%></td>
                            <td><%=u.getEmail()%></td>
                            <td><%=u.getFirstName()%></td>
                            <td><%=u.getSecondName()%></td>
                        </tr>
                        <%              }
                                }
                            }
                        %>
                        <tr>
                            <td colspan="6">
                                <input type="submit" name="delete" value="Delete" style="float: right;">
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </form>
    </div>
</div>
